<template>
  <ant-modal
    modalWidth="800"
    modalHeight="600"
    :visible="open"
    :modal-title="formTitle"
    :adjust-size="true"
    @cancel="cancel"
  >
    <a-form-model
      ref="form"
      :model="form"
      :rules="rules"
      slot="content"
      layout="vertical"
    >
      <a-row :gutter="32" style="width: 96%; margin-left: 2%">
        <a-col :span="12">
          <a-form-model-item
            label="城市"
            prop="ruleCities"
            :labelCol="{ span: 4 }"
            :wrapperCol="{ span: 18 }"
          >
            <a-select
              placeholder="请选择城市"
              v-model="form.ruleCities"
              :getPopupContainer="
                (triggerNode) => {
                  return triggerNode.parentNode || document.body;
                }
              "
              style="width: 100%"
              @change="onCityChange"
            >
              <a-select-option
                v-for="(d, index) in cityOptions"
                :key="index"
                :value="d.name.replace('市', '')"
                >{{ d.name }}</a-select-option
              >
            </a-select>
          </a-form-model-item>
        </a-col>

        <a-col :span="12">
          <a-form-model-item
            label="最大接单量"
            prop="isEnable"
            :labelCol="{ span: 6 }"
            :wrapperCol="{ span: 18 }"
          >
            <a-input-number
              v-model="form.maxCount"
              :min="0"
              :max="100"
              :step="1"
              :precision="0"
              style="width: 100%"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row :gutter="32" style="width: 96%; margin-left: 2%">
        <a-col :span="24">
          <a-form-model-item
            label="来源"
            prop="laiyuan"
            :labelCol="{ span: 2 }"
            :wrapperCol="{ span: 22 }"
          >
            <a-select
              placeholder="请选择客户来源"
              v-model="form.laiyuan"
              :getPopupContainer="
                (triggerNode) => {
                  return triggerNode.parentNode || document.body;
                }
              "
              style="width: 100%"
              mode="multiple"
              allow-clear
              @select="handleLaiyuanAdd"
              @deselect="handleLaiyuanRemove"
            >
              <a-select-option
                v-for="(dict, index) in laiyuanOptions"
                :key="index"
                :value="dict.dictValue"
                >{{ dict.dictLabel }}</a-select-option
              >
            </a-select>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="24">
          <a-table
            rowKey="laiyuan"
            size="middle"
            :columns="columns"
            :data-source="tableData"
            :scroll="{ x: 'calc(200px + 50%)' }"
            bordered
            :pagination="false"
            ><span slot="isEnable" slot-scope="text, record">
              <a-switch
                v-model="record.isEnable"
                checked-children="是"
                un-checked-children="否"
              />
            </span>
            <span slot="maxCount" slot-scope="text, record">
              <a-input-number
                v-model="record.maxCount"
                :min="0"
                :max="10000"
                placeholder="1-10000"
                :precision="0"
                allow-clear
                style="width: 80%"
              />
            </span>
            <span slot="remark" slot-scope="text, record">
              <a-input v-model="record.remark" allow-clear style="width: 80%" />
            </span>
          </a-table>
        </a-col>
      </a-row>
    </a-form-model>
    <template slot="footer">
      <a-button @click="cancel"> 取消 </a-button>
      <a-button type="primary" @click="submitForm"> 保存 </a-button>
    </template>
  </ant-modal>
</template>
<script>
import BizPushRuleByUserForm from "./BizPushRuleByUserForm";
export default {
  ...BizPushRuleByUserForm,
};
</script>
